home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!news
- From: rclark@iquest.net (Robert B. Clark)
- Subject: Re: SYSTEM CALL in a while loop didn't work
- X-Nntp-Posting-Host: ind-007-237-42.iquest.net
- Message-ID: <31178e3b.14884@news.iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Internet, Inc.
- X-Newsreader: Forte Agent .99c/16.141
- References: <4f53vi$5uo@bcrkh13.bnr.ca>
- Date: Tue, 6 Feb 1996 17:38:49 GMT
-
- On 5 Feb 1996 14:24:50 GMT, coopeng <coopeng@bnr.ca> wrote:
-
- >while()
- > while()
- > */first system call */
- > while()/*rubing*/
- > strstr()
- > */second system call */
- >
- >first system call works, but second doesn't. If I comment the third while loop then
- >second while loop also works. I shall be thankful if you guys mail me the
-
- Can't really tell from the p-code you've posted--what you've written
- looks something like this:
-
- while() /* Assume this evaluates to true...? */
- {
- while(system())
- while(strstr());
- }
- system();
-
- The braces were implied in your code; I've added them here for clarity.
-
- If this is what you have, the second system call will only run if the
- outermost while loop fails. The first system call will run at least
- once if the outer while is met, and may very well fall into an infinite
- loop depending on its return value--system() returns 0 (false) if no
- error, -1 (true) otherwise.
-
- Since you said that the first system call executes, I can assume that
- the parameter expression for the outermost while evaluates to true--at
- least, initially.
-
- The innermost while statement will either fail (strstr() returns NULL)
- or run indefinitely (strstr() returns char pointer to matched
- substring).
-
- In short, I'm fairly certain that this is not what you meant, so could
- you post the actual code please?
- --
- Robert B. Clark <rclark@iquest.net>
- "Be wary of strong spirits. It can make you shoot at tax collectors...
- and miss." --RAH
-